package com.heima.feigins;

import com.heima.config.HeimaFeiginAutoConfiguration;
import com.heima.feigins.fallback.WemediaFeiginFallback;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.model.wemedia.pojos.WmUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

//value--服务名称，fallbackFactory服务降级，configuration配置类
@FeignClient(value = "leadnews-wemedia",fallbackFactory = WemediaFeiginFallback.class,configuration = HeimaFeiginAutoConfiguration.class)
public interface WemediaFigin {
    /*
    * 根据名称查询用户信息
    * */
    @GetMapping("/api/v1/user/findByName/{name}")
    public ResponseResult<WmUser> findByName(@PathVariable String name);
    //保存用户信息
    @PostMapping("/api/v1/user/save")
    public ResponseResult<WmUser> save(@RequestBody WmUser wmUser);

    /*
    * 根据id查询自媒体文章信息
    * */
    @GetMapping("/api/v1/news/one/{id}")
    public ResponseResult<WmNews> findNewsById(@PathVariable("id") Integer id);

    /*
    * 修该自媒体文章信息
    * */
    @PutMapping("/api/v1/news/update")
    public ResponseResult<WmNews> updateWmNews(@RequestBody WmNews wmNews);
}
